<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: General Functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__profile__functions__general.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">General Functions<div class="ingroups"><a class="el" href="group__group__energy__profiler.html">Profile      (Energy Profiler)</a> &raquo; <a class="el" href="group__group__profile__functions.html">Functions</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga3a4f9cb2191f4c950821aca1c56766b2"><td class="memItemLeft" align="right" valign="top">__STATIC_INLINE void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__general.html#ga3a4f9cb2191f4c950821aca1c56766b2">Cy_Profile_Init</a> (void)</td></tr>
<tr class="memdesc:ga3a4f9cb2191f4c950821aca1c56766b2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes and enables the profile hardware.  <a href="#ga3a4f9cb2191f4c950821aca1c56766b2">More...</a><br /></td></tr>
<tr class="separator:ga3a4f9cb2191f4c950821aca1c56766b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf60450e95c581d875f6eed5fa01f84eb"><td class="memItemLeft" align="right" valign="top">__STATIC_INLINE void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__general.html#gaf60450e95c581d875f6eed5fa01f84eb">Cy_Profile_DeInit</a> (void)</td></tr>
<tr class="memdesc:gaf60450e95c581d875f6eed5fa01f84eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clears the interrupt mask and disables the profile hardware.  <a href="#gaf60450e95c581d875f6eed5fa01f84eb">More...</a><br /></td></tr>
<tr class="separator:gaf60450e95c581d875f6eed5fa01f84eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad8b4c8660845665052ffc891d9b1cd50"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a> (void)</td></tr>
<tr class="memdesc:gad8b4c8660845665052ffc891d9b1cd50"><td class="mdescLeft">&#160;</td><td class="mdescRight">Starts the profiling/measurement window.  <a href="#gad8b4c8660845665052ffc891d9b1cd50">More...</a><br /></td></tr>
<tr class="separator:gad8b4c8660845665052ffc891d9b1cd50"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4a4a1151a6c68338ab316b8119ae91ec"><td class="memItemLeft" align="right" valign="top">__STATIC_INLINE void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a> (void)</td></tr>
<tr class="memdesc:ga4a4a1151a6c68338ab316b8119ae91ec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stops the profiling/measurement window.  <a href="#ga4a4a1151a6c68338ab316b8119ae91ec">More...</a><br /></td></tr>
<tr class="separator:ga4a4a1151a6c68338ab316b8119ae91ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga941794243fc79c08dd1f644bf916cc18"><td class="memItemLeft" align="right" valign="top">__STATIC_INLINE uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__general.html#ga941794243fc79c08dd1f644bf916cc18">Cy_Profile_IsProfiling</a> (void)</td></tr>
<tr class="memdesc:ga941794243fc79c08dd1f644bf916cc18"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reports the active status of the profiling window.  <a href="#ga941794243fc79c08dd1f644bf916cc18">More...</a><br /></td></tr>
<tr class="separator:ga941794243fc79c08dd1f644bf916cc18"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga3a4f9cb2191f4c950821aca1c56766b2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3a4f9cb2191f4c950821aca1c56766b2">&#9670;&nbsp;</a></span>Cy_Profile_Init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">__STATIC_INLINE void Cy_Profile_Init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes and enables the profile hardware. </p>
<p>This function must be called once when energy profiling is desired. The operation does not start a profiling session.</p>
<dl class="section note"><dt>Note</dt><dd>The profile interrupt must also be configured. <a class="el" href="group__group__profile__functions__interrupt.html#gaf530fa03abe1f90c9788ed4ee1ed140f">Cy_Profile_ISR()</a> can be used as its handler.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The Energy Profiler block needs to be initialized before </span></div><div class="line"><span class="comment">                 configuring the profile counters. The profile interrupt is</span></div><div class="line"><span class="comment">                 configured using the sysint driver. Its handler function </span></div><div class="line"><span class="comment">                 is Cy_Profile_ISR(). It is enabled using NVIC_EnableIRQ(). */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* Initialize the energy profiler */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga3a4f9cb2191f4c950821aca1c56766b2">Cy_Profile_Init</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Clear all counter configurations */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__counter.html#gaa727295348b428f46dc3d0a7e1f1681f">Cy_Profile_ClearConfiguration</a>();</div><div class="line"></div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="gaf60450e95c581d875f6eed5fa01f84eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf60450e95c581d875f6eed5fa01f84eb">&#9670;&nbsp;</a></span>Cy_Profile_DeInit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">__STATIC_INLINE void Cy_Profile_DeInit </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Clears the interrupt mask and disables the profile hardware. </p>
<p>This function should be called when energy profiling is no longer desired.</p>
<dl class="section note"><dt>Note</dt><dd>The profile interrupt is not disabled by this operation and must be disabled separately.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The energy profiler is no longer required and needs to be</span></div><div class="line"><span class="comment">                 turned off. All profile counters are disabled. The profile </span></div><div class="line"><span class="comment">                 interrupt is also disabled using NVIC_DisableIRQ(). */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* Stop profiling */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Turn off the energy profiler */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#gaf60450e95c581d875f6eed5fa01f84eb">Cy_Profile_DeInit</a>();</div><div class="line"></div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="gad8b4c8660845665052ffc891d9b1cd50"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad8b4c8660845665052ffc891d9b1cd50">&#9670;&nbsp;</a></span>Cy_Profile_StartProfiling()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cy_Profile_StartProfiling </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Starts the profiling/measurement window. </p>
<p>This operation allows the enabled profile counters to start counting.</p>
<dl class="section note"><dt>Note</dt><dd>The profile interrupt should be enabled before calling this function for the firmware to be notified when a counter overflow occurs.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The CM0 activity needs to be monitored during a fixed</span></div><div class="line"><span class="comment">                 window. The profile interrupt is configured using the sysint </span></div><div class="line"><span class="comment">                 driver. Its handler function is Cy_Profile_ISR(). The interrupt</span></div><div class="line"><span class="comment">                 is enabled using NVIC_EnableIRQ(). */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Initialize the energy profiler */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga3a4f9cb2191f4c950821aca1c56766b2">Cy_Profile_Init</a>();</div><div class="line">    <a class="code" href="group__group__profile__functions__counter.html#gaa727295348b428f46dc3d0a7e1f1681f">Cy_Profile_ClearConfiguration</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Configure a profile counter to monitor the CM0 activity and enable it */</span></div><div class="line">    cntHandle[0] = <a class="code" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter</a>(CPUSS_MONITOR_CM0,      <span class="comment">/* CM0 active cycles count */</span></div><div class="line">                                               <a class="code" href="group__group__profile__enums.html#gga82efb19440328ed10ceb3ae66ac4e6f3a4164d3e39093109cb37d74adac47c6c3">CY_PROFILE_EVENT</a>,       <span class="comment">/* Count number of active cycles */</span></div><div class="line">                                               <a class="code" href="group__group__profile__enums.html#ggaf4167388440a79a2671d7c1bea86785cab734f4cdfa75f56ad1bbecdfd22dc137">CY_PROFILE_CLK_TIMER</a>,   <span class="comment">/* Ignored for &quot;event&quot; counting */</span></div><div class="line">                                               10UL);                  <span class="comment">/* Weight of 10 (example) */</span></div><div class="line">    <span class="comment">/* Enable the assigned counter */</span></div><div class="line">    (void)<a class="code" href="group__group__profile__functions__counter.html#gadb0af4c3dfab0094b3c37192f600f351">Cy_Profile_EnableCounter</a>(cntHandle[0]);</div><div class="line"></div><div class="line">    <span class="comment">/* Start the profiling window. */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* When ready to read the result, stop the profiling window */</span></div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga4a4a1151a6c68338ab316b8119ae91ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4a4a1151a6c68338ab316b8119ae91ec">&#9670;&nbsp;</a></span>Cy_Profile_StopProfiling()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">__STATIC_INLINE void Cy_Profile_StopProfiling </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Stops the profiling/measurement window. </p>
<p>This operation prevents the enabled profile counters from counting.</p>
<dl class="section note"><dt>Note</dt><dd>The profile interrupt should be disabled before calling this function.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The weighted average of all the counter values in the profiling</span></div><div class="line"><span class="comment">                 window needs to be read. The energy profiler and the profile</span></div><div class="line"><span class="comment">                 interrupt are initialized and enabled. The profile counters</span></div><div class="line"><span class="comment">                 are configured and enabled. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Start the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Perform some activity... */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* When ready to read the results of the counter values, stop the profiling window. */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Energy limit (example) of a profiling window */</span></div><div class="line">    uint64_t energyLimit =  0x00100000UL;</div><div class="line">    </div><div class="line">    <span class="comment">/* Get the weighted average of all the counter values */</span></div><div class="line">    uint64_t weightedAvg = <a class="code" href="group__group__profile__functions__calculation.html#gaf7064fd5a7d413a42fb9d3053cf8f8ea">Cy_Profile_GetSumWeightedCounts</a>(cntHandle, PROFILE_PRFL_CNT_NR);</div><div class="line">    </div><div class="line">    <span class="keywordflow">if</span>(weightedAvg &gt; energyLimit)</div><div class="line">    {</div><div class="line">        <span class="comment">/* The energy consumption is more than expected for this profiling window.</span></div><div class="line"><span class="comment">           Take appropriate measures to reduce the energy consumption. */</span></div><div class="line">    }</div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga941794243fc79c08dd1f644bf916cc18"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga941794243fc79c08dd1f644bf916cc18">&#9670;&nbsp;</a></span>Cy_Profile_IsProfiling()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">__STATIC_INLINE uint32_t Cy_Profile_IsProfiling </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reports the active status of the profiling window. </p>
<dl class="section return"><dt>Returns</dt><dd>0 = profiling is not active; 1 = profiling is active</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The status of the profiling window needs to be known to make</span></div><div class="line"><span class="comment">                 a determination as to whether to start a profiling window</span></div><div class="line"><span class="comment">                 or to stop it. */</span></div><div class="line">    </div><div class="line">    <span class="keywordflow">if</span>(1UL == <a class="code" href="group__group__profile__functions__general.html#ga941794243fc79c08dd1f644bf916cc18">Cy_Profile_IsProfiling</a>())</div><div class="line">    {</div><div class="line">        <span class="comment">/* Stop the profiling window */</span></div><div class="line">        <a class="code" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a>();</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        <span class="comment">/* Start the profiling window */</span></div><div class="line">        <a class="code" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a>();</div><div class="line">    }</div><div class="line"></div></div><!-- fragment --></dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
